<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >

                <p:focus id="selectFocus" context="gpSelect" />
                <p:focus id="detailFocus" context="gpDetail" />



                <p:panel header="Manage Institution Branch" >

                    <div id="Temp" style="position: relative;left:0%;">
                        <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop">

                            <h:panelGrid id="gpSelect" columns="1"  >

                                <p:panel >
                                    <h:panelGrid id="gpSelectText" >
                                        <h:inputText autocomplete="off" id="txtSearch" value="#{institutionBranchController.selectText}" >
                                            <f:ajax execute="txtSearch" render="lstSelect" event="keyup" />
                                        </h:inputText>

                                        <p:selectOneListbox  id="lstSelect"   value="#{institutionBranchController.current}" style="min-width: 223px; height: 300px;">
                                            <f:selectItems  value="#{institutionBranchController.selectedItems}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                            <p:ajax event="change"   update="gpDetail" process="lstSelect" >
                                            </p:ajax>
                                        </p:selectOneListbox>

                                    </h:panelGrid>
                                    <h:panelGrid id="gpSelectButtons" columns="3"  >
                                        <h:commandButton id="btnAdd" value="Add" action="#{institutionBranchController.prepareAdd()}" styleClass="buttons" >
                                        </h:commandButton>
                                        <h:commandButton id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                    return false;" action="#{institutionBranchController.delete()}"  value="Delete"  >
                                        </h:commandButton>
                                    </h:panelGrid>
                                </p:panel>
                            </h:panelGrid  >

                            <p:panel>

                                <h:panelGrid id="gpDetail" columns="1">
                                    <h:panelGrid id="gpDetailText" columns="2">
                                        <h:outputText  value="Branch Name" ></h:outputText>
                                        <h:inputText autocomplete="off"  value="#{institutionBranchController.current.name}"  ></h:inputText>
                                        <h:outputText value="Branch Code" >                                        
                                        </h:outputText>
                                        <h:inputText autocomplete="off"  value="#{institutionBranchController.current.institutionCode}"  >
                                        </h:inputText>   
                                        <h:outputText value="Bank" ></h:outputText>
                                        <h:selectOneListbox id="cmbIns" value="#{institutionBranchController.current.institution}" size="1">
                                            <f:selectItem itemLabel="Select the Institution" />
                                            <f:selectItems value="#{institutionController.banks}" var="i" itemLabel="#{i.name}" itemValue="#{i}" />
                                        </h:selectOneListbox>
                                    </h:panelGrid>
                                    <h:panelGrid id="gpDetailButtons" columns="2">
                                        <h:commandButton id="btnSave" value="Save" action="#{institutionBranchController.saveSelected()}" styleClass="buttons">
                                        </h:commandButton>
                                        <p:defaultCommand target="btnSave"/>
                                    </h:panelGrid>
                                </h:panelGrid>

                            </p:panel>


                        </h:panelGrid>

                    </div>
                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
